/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.klikmee.sms.core.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 * 
 * @author makcro
 */
@Entity
@Table(name = "paymentinvoice", uniqueConstraints = {
		@UniqueConstraint(columnNames = { "Id" }) })
@NamedQueries({
		@NamedQuery(name = "PaymentInvoice.findAll", query = "SELECT p FROM PaymentInvoice p"),
		@NamedQuery(name = "PaymentInvoice.findById", query = "SELECT p FROM PaymentInvoice p WHERE p.id = :id"),
		@NamedQuery(name = "PaymentInvoice.findByCreated", query = "SELECT p FROM PaymentInvoice p WHERE p.created = :created"),
		@NamedQuery(name = "PaymentInvoice.findByMTSChargeTime", query = "SELECT p FROM PaymentInvoice p WHERE p.mTSChargeTime = :mTSChargeTime"),
		@NamedQuery(name = "PaymentInvoice.findByMTSSubscriberType", query = "SELECT p FROM PaymentInvoice p WHERE p.mTSSubscriberType = :mTSSubscriberType"),
		@NamedQuery(name = "PaymentInvoice.findByMTSMessageId", query = "SELECT p FROM PaymentInvoice p WHERE p.mTSMessageId = :mTSMessageId"),
		@NamedQuery(name = "PaymentInvoice.findByOurMTSChargeTime", query = "SELECT p FROM PaymentInvoice p WHERE p.ourMTSChargeTime = :ourMTSChargeTime"),
		@NamedQuery(name = "PaymentInvoice.findByState", query = "SELECT p FROM PaymentInvoice p WHERE p.state = :state"),
		@NamedQuery(name = "PaymentInvoice.findByStateChangeTime", query = "SELECT p FROM PaymentInvoice p WHERE p.stateChangeTime = :stateChangeTime"),
		@NamedQuery(name = "PaymentInvoice.findByType", query = "SELECT p FROM PaymentInvoice p WHERE p.type = :type") })
public class PaymentInvoice implements Serializable {

	private static final long		serialVersionUID	= 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	@Column(name = "Id", nullable = false)
	private Long					id;
	@Column(name = "Created")
	@Temporal(TemporalType.TIMESTAMP)
	private Date					created;
	@Column(name = "MTSChargeTime")
	@Temporal(TemporalType.TIMESTAMP)
	private Date					mTSChargeTime;
	@Column(name = "MTSSubscriberType")
	private Integer					mTSSubscriberType;
	@Column(name = "MTSMessageId", length = 100)
	private String					mTSMessageId;
	@Column(name = "OurMTSChargeTime")
	@Temporal(TemporalType.TIMESTAMP)
	private Date					ourMTSChargeTime;
	@Column(name = "State")
	private Integer					state;
	@Column(name = "StateChangeTime")
	@Temporal(TemporalType.TIMESTAMP)
	private Date					stateChangeTime;
	@Column(name = "Type")
	private Integer					type;
	@JoinColumn(name = "ServiceChargingCategoryId", referencedColumnName = "Id")
	@ManyToOne
	private ServiceChargingCategory	serviceChargingCategory;
	@JoinColumn(name = "IncomingMessageId", referencedColumnName = "Id")
	@ManyToOne(cascade = CascadeType.MERGE)
	private IncomingMessage			incomingMessage;
	@JoinColumn(name = "OutGoingMessageId", referencedColumnName = "Id")
	@ManyToOne(cascade = CascadeType.MERGE)
	private OutgoingMessage			outgoingMessage;
	

	public PaymentInvoice() {
	}

	public PaymentInvoice( ServiceChargingCategory servicechargingcategory,
							IncomingMessage incomingmessage, OutgoingMessage outgoingmessage,
							Date created,
							Date mtschargeTime, Integer mtssubscriberType, String mtsmessageId,
							Date ourMtschargeTime, Integer state, Date stateChangeTime,
							Integer type ) {
		this.serviceChargingCategory = servicechargingcategory;
		this.incomingMessage = incomingmessage;
		this.outgoingMessage = outgoingmessage;
		this.created = created;
		this.mTSChargeTime = mtschargeTime;
		this.mTSSubscriberType = mtssubscriberType;
		this.mTSMessageId = mtsmessageId;
		this.ourMTSChargeTime = ourMtschargeTime;
		this.state = state;
		this.stateChangeTime = stateChangeTime;
		this.type = type;
	}

	public PaymentInvoice( ServiceChargingCategory serviceChargingCategory,
							IncomingMessage incomingMessage, OutgoingMessage outgoingMessage,
							int state, Date stateChangeTime, int type, Date created ) {
		this.serviceChargingCategory = serviceChargingCategory;
		this.incomingMessage = incomingMessage;
		this.outgoingMessage = outgoingMessage;
		this.state = state;
		this.stateChangeTime = stateChangeTime;
		this.type = type;
		this.created = created;
	}

	public PaymentInvoice( Long id ) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setId( Long id ) {
		this.id = id;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated( Date created ) {
		this.created = created;
	}

	public Date getMTSChargeTime() {
		return mTSChargeTime;
	}

	public void setMTSChargeTime( Date mTSChargeTime ) {
		this.mTSChargeTime = mTSChargeTime;
	}

	public Integer getMTSSubscriberType() {
		return mTSSubscriberType;
	}

	public void setMTSSubscriberType( Integer mTSSubscriberType ) {
		this.mTSSubscriberType = mTSSubscriberType;
	}

	public String getMTSMessageId() {
		return mTSMessageId;
	}

	public void setMTSMessageId( String mTSMessageId ) {
		this.mTSMessageId = mTSMessageId;
	}

	public Date getOurMTSChargeTime() {
		return ourMTSChargeTime;
	}

	public void setOurMTSChargeTime( Date ourMTSChargeTime ) {
		this.ourMTSChargeTime = ourMTSChargeTime;
	}

	public Integer getState() {
		return state;
	}

	public void setState( Integer state ) {
		this.state = state;
		this.stateChangeTime = new Date();
	}

	public Date getStateChangeTime() {
		return stateChangeTime;
	}

	public void setStateChangeTime( Date stateChangeTime ) {
		this.stateChangeTime = stateChangeTime;
	}

	public Integer getType() {
		return type;
	}

	public void setType( Integer type ) {
		this.type = type;
	}

	public ServiceChargingCategory getServiceChargingCategory() {
		return serviceChargingCategory;
	}

	public void setServiceChargingCategory( ServiceChargingCategory serviceChargingCategory ) {
		this.serviceChargingCategory = serviceChargingCategory;
	}

	public IncomingMessage getIncomingMessage() {
		return incomingMessage;
	}

	public void setIncomingMessage( IncomingMessage incomingMessage ) {
		this.incomingMessage = incomingMessage;
	}

	public OutgoingMessage getOutgoingMessage() {
		return outgoingMessage;
	}

	public void setOutgoingMessage( OutgoingMessage outgoingMessage ) {
		this.outgoingMessage = outgoingMessage;
	}


	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals( Object object ) {
		if (!(object instanceof PaymentInvoice)) {
			return false;
		}
		PaymentInvoice other = (PaymentInvoice) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals( other.id ))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "com.klikmee.sms.core.entities.PaymentInvoice[id=" + id + "]";
	}
}
